﻿using BW.MesProject.Production.Domain.Dto.Input;
using BW.MesProject.Production.Domain.Dto.Input.Packing;
using BW.MesProject.Production.Domain;
using BW.MesProject.Production.Infrastructure;
using BW.MesProject.Public.ErrorCode;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Models;

namespace BW.MesProject.Production.Host.Controllers
{
    /// <summary>
    /// 包装规格控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PackingController : ControllerBase
    {
        public readonly IPackingServices _packingServices;
        public PackingController(IPackingServices packingServices)
        {
            _packingServices = packingServices;
        }
        /// <summary>
        /// 添加包装规格
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> CreatePacking(AddPackingInput input)
        {
            return _packingServices.CreatePacking(input);
        }
        /// <summary>
        /// 获取包装规格信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<PackingInput> GetPackingById(long id)
        {
            return _packingServices.GetPackingById(id); 
        }
        /// <summary>
        /// 获取包装规格列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<PACKINGMODEL>> GetPackingList()
        {
            return _packingServices.GetPackingList();
        }
        /// <summary>
        /// 修改包装规格信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdatePacking(PackingInput input)
        {
            return _packingServices.UpdatePacking(input);
        }
        /// <summary>
        /// 删除包装规格信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> DeletePacking(long id)
        {
            return _packingServices.DeletePacking(id);
        }
    }
}
